package com.example.qcweb;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageButton;
import android.widget.TextView;

import com.example.dao.DBDao;
import com.example.modal.QcCard;
import com.example.qc.R;

public class QCCardViewActivity extends Activity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        //无标题栏
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.activity_qccardinfo);
        /*Intent intent=getIntent();
		Bundle bundle=intent.getExtras();
		String cardcode=bundle.getString("card");*/

        TextView tv1 = (TextView) findViewById(R.id.TV1);
        TextView tv2 = (TextView) findViewById(R.id.TV2);
        TextView tv3 = (TextView) findViewById(R.id.TV3);
        TextView tv4 = (TextView) findViewById(R.id.TV4);
        TextView tv5 = (TextView) findViewById(R.id.TV5);
        TextView tv6 = (TextView) findViewById(R.id.TV6);
        TextView tv7 = (TextView) findViewById(R.id.TV7);
        TextView tv8 = (TextView) findViewById(R.id.TV8);
        QcCard qcCard = DBGlobal.GetCardInfo(MyGlobal.KeycardCode, QCCardViewActivity.this);
        boolean isGuanjian = DBDao.isGj(MyGlobal.KeycardCode);
        boolean isJunjian = DBDao.isJJ(MyGlobal.KeycardCode);
        tv1.setText(qcCard.getProductModel());
        tv2.setText(qcCard.getDrawingNumber());
        tv3.setText(qcCard.getProductName());
        tv4.setText(qcCard.getProductBatchNumber());
        tv5.setText(qcCard.getTaskNumber());
        tv6.setText(qcCard.getProductNumber());
        if (isGuanjian) {
            tv7.setText("是");
        } else {
            tv7.setText("否");
        }

        if (isJunjian) {
            tv8.setText("是");
        } else {
            tv8.setText("否");
        }

        ImageButton ibtnButton = (ImageButton) findViewById(R.id.imgbtnstart);
        ibtnButton.setOnClickListener(new BtnClick());
        ImageButton imgbtnLog = (ImageButton) findViewById(R.id.imgbtnlog);
        imgbtnLog.setOnClickListener(new BtnClick());

    }

    public class BtnClick implements OnClickListener {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            ImageButton btn = (ImageButton) v;
            switch (btn.getId()) {
                case R.id.imgbtnstart:
                    Intent intent = new Intent();
                    intent.setClass(QCCardViewActivity.this, Gongyi_Activity.class);
                    startActivity(intent);
                    break;
                case R.id.imgbtnlog:

                    break;
                default:
                    break;
            }

        }
    }
}
